//
//  TF_PlayBackPPTView.swift
//  TalkfunSDKDemo
//
//  Created by 邓盛明 on 2021/12/13.
//  Copyright © 2021 Talkfun. All rights reserved.
//

import UIKit
public typealias ZSTapGestureBlock = () -> ()
public typealias ZSDoubleTapGestureBlock = (_ tapGR:UITapGestureRecognizer) -> ()
public typealias ZSPanGestureBlock = (_ panGR:UIPanGestureRecognizer) -> ()

class TF_PlayBackPPTView: UIView,UIGestureRecognizerDelegate {
 
    @objc public var tapGestueBlock:ZSTapGestureBlock?
    @objc public var doubleTapGestureBlock:ZSDoubleTapGestureBlock?
    @objc public var panGestueBlock:ZSPanGestureBlock?
  
    override init(frame: CGRect) {
        super.init(frame: frame)
        //pptview加点击手势
        let tapGesture = UITapGestureRecognizer.init(target: self, action: #selector(tapGestureGR(tap:)))
        tapGesture.delegate = self
        self.addGestureRecognizer(tapGesture)
       
     
        //pptview加双击手势
        let doubleTapGesture = UITapGestureRecognizer.init(target: self, action: #selector(doubleTapGR(doubletap:)))
      
        doubleTapGesture.numberOfTapsRequired = 2;
        doubleTapGesture.delegate = self;
        self.addGestureRecognizer(doubleTapGesture)
       
        //快进快退手势依赖添加双击手势
        let panGesture = UIPanGestureRecognizer.init(target: self, action: #selector(panGestureGR(panGr:)))
  
        panGesture.delegate = self;
        self.addGestureRecognizer(panGesture)
       
    
        //快进快退手势依赖添加双击手势
        tapGesture.require(toFail: doubleTapGesture)

         //快进快退手势依赖添加单击手势
        tapGesture.require(toFail: panGesture)

    }
    
    @objc func tapGestureGR(tap:UITapGestureRecognizer)  {
        if self.tapGestueBlock != nil {
            self.tapGestueBlock?()
        }
    }
    
    @objc func panGestureGR(panGr:UIPanGestureRecognizer)  {
        if self.panGestueBlock != nil {
            self.panGestueBlock?(panGr)
        }
     }
     
    @objc func doubleTapGR(doubletap:UITapGestureRecognizer)  {
        if self.doubleTapGestureBlock != nil {
            self.doubleTapGestureBlock?(doubletap)
        }
     }
     
    
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
